<template>
  <div class="articleContainer">
    <div class="header">
      <SiderHeader title="资源管理器">
        <template #right_Icon>
          <H-tips title="新建文件夹" position="bottom">
            <div class="rightIcon Icon">
              <Icon-add-folder width="16" height="16" @click="fileAddFn"></Icon-add-folder>
            </div>
          </H-tips>
        </template>
      </SiderHeader>
    </div>
    <div class="main">
      <H-collapse sign="add">
        <template v-for="item, index in fileInfo.fileList" :key="index">
          <H-collapseItem :title="item.title">
            <template #right_Icon>
              <div class="right_Icon">
                <H-tips title="新建文件" position="bottom">
                  <div class="addFile Icon">
                    <Icon-file-add width="16" height="16" @click="fileItemAddFn"></Icon-file-add>
                  </div>
                </H-tips>
                <H-tips title="重命名" position="bottom">
                  <div class="reName Icon">
                    <Icon-edit width="16" height="16" @click="fileReNameFn"></Icon-edit>
                  </div>
                </H-tips>
                <H-tips title="删除文件夹" position="bottom">
                  <div class="deleteFile Icon">
                    <Icon-delete-light width="16" height="16" @click="fileDeleteFn"></Icon-delete-light>
                  </div>
                </H-tips>
              </div>
            </template>
            <template #content>
              <div class="content scroll">
                <H_NoDate v-if="item.children"></H_NoDate>
                <H-list v-else :data="item.children || []"></H-list>
              </div>
            </template>
          </H-collapseItem>
        </template>
      </H-collapse>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import SiderHeader from '@/components/sidebar/header/index.vue'
import H_NoDate from '@/components/noDate/index.vue'
import fileStore, { listType } from '@/store/file'
const fileInfo = fileStore()
const fileAddFn = (e: MouseEvent) => {
  e.stopPropagation()
  const newFile: listType[] = [{
    title: '',
    key: new Date().getTime(),
    children: []
  }]
  fileInfo.addFile(newFile, 0)

}
const fileItemAddFn = (e: MouseEvent) => {
  e.stopPropagation()
}
const fileReNameFn = (e: MouseEvent) => {
  e.stopPropagation()
}
const fileDeleteFn = (e: MouseEvent) => {
  e.stopPropagation()
}
</script>
<style scoped lang="less">
.articleContainer {
  height: 100%;
  display: flex;
  flex-direction: column;

  .Icon {
    padding-right: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px;

    &:hover {
      background-color: var(---E5E5CB);
      border-radius: 2px;
    }
  }

  .header {}


  .main {
    flex: 1;

    .content {
      min-height: 200px;
      height: 100%;
      overflow-y: scroll;

    }

    .right_Icon {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .Icon {
        padding-right: 2px;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 2px;

        &:hover {
          background-color: var(---E5E5CB);
          border-radius: 2px;
        }
      }
    }
  }

}
</style>